JavaScript Mapper Import Function
The JavaScript mapper file in your integration must implement a method named 'import'.
The import method is expected to transform the given template output into minimal Policy Manager entities representing the state of the device being imported.
Output Format
We use the term 'minimal Policy Manager entities' to refer to items which Policy Manager can normalize into full Policy Manager entities.
The import method receives two arguments:
- targetTemplateResults: The results of all target templates, given as an array.
- policyTemplateResults : The results of all policy templates, given as an array.
The specifics of each element in the above arguments will depend entirely on the design of your templates. Policy Manager makes no modifications to these outputs before passing them to the mapper import method.
The import method is expected to return an object with two mandatory keys:
- targets: An array containing Policy Manager target entities.
- policies: An array containing Policy Manager policy entities.
Example
This section provides example input and output from Policy Manager's internal Cisco IOS integration.
An output from the IPv4 target template (an example template is given in the Target Import Template guide):
{
"ADDRESS_TYPE": "Internet",
"INTERFACE": "GigabitEthernet1",
"ADDRESS": "10.1.3.198/24",
"OUTBOUND_POLICY": "pm-test-ext-1",
"INBOUND_POLICY": "not set"
}
The resulting minimal Policy Manager target entity:
{
"name": "GigabitEthernet1_out",
"addressType": "IPv4",
"sourceNetworks": [
"0.0.0.0/0"
],
"destinationNetworks": [
"10.1.3.198/24"
],
"policy": "pm-test-ext-1"
}
An output from the IPv4 policy import template:
[
{
"ADDRESS_TYPE": "IP",
"LIST_TYPE": "Extended",
"NAME": "pm-test-ext-1",
"SN": "10",
"ACTION": "permit",
"PROTOCOL": "tcp",
"SOURCE": "any",
"SOURCE_PORT": "",
"DESTINATION": "any",
"DESTINATION_PORT": "",
"MODIFIER": "log"
},
{
"ADDRESS_TYPE": "IP",
"LIST_TYPE": "Extended",
"NAME": "pm-test-ext-1",
"SN": "20",
"ACTION": "permit",
"PROTOCOL": "icmp",
"SOURCE": "any",
"SOURCE_PORT": "",
"DESTINATION": "any",
"DESTINATION_PORT": "",
"MODIFIER": ""
}
]
The resulting minimal Policy Manager policy entity:
{
"name": "pm-test-ext-1",
"policyType": "acl",
"addressType": "IPv4",
"rules": [
{
"name": "pm-test-ext-1_rule67",
"action": "permit",
"sourceNetworks": [
"0.0.0.0/0"
],
"destinationNetworks": [
"0.0.0.0/0"
],
"services": [
{
"protocol": 6
}
],
"logging": true,
"templateReference": null,
"enabled": true
},
{
"name": "pm-test-ext-1_rule68",
"action": "permit",
"sourceNetworks": [
"0.0.0.0/0"
],
"destinationNetworks": [
"0.0.0.0/0"
],
"services": [
{
"protocol": 1
}
],
"logging": false,
"templateReference": null,
"enabled": true
}
]
}
For a more in depth guide to minimal Policy Manager entities, see the associated documentation.